#include "simple_string_owner.h"
#include <iostream>

void fnC() {
  // 这里会抛出异常，导致栈展开
  SimpleStringOwner c{"ccccccccccccc"};
}

void fnB() {
  SimpleStringOwner b{"b"};
  fnC();
}

// 调用栈展开
void statckUnwind() {
  try {
    SimpleStringOwner a{"a"};
    fnB();
    SimpleStringOwner d{"d"};
  } catch (const std::exception &e) {
    printf("Exception: %s\n", e.what());
  }
}

int main(int argc, char *argv[]) {
  std::cout << "==== ch04 p04 ====" << std::endl;
  statckUnwind();
  return 0;
}
